<?php
require_once("../models/Unit.php");
class StartContractController{
	var $pass;
	var $name;
	var $homeaddress;
	var $studnum;
	var $cellnum;
	var $course;
	var $college;
	var $classification;
	var $parents;
	var $contact;
	var $occupants;
	var $deposit;
	var $rent;
	var $start;
	var $debts;
	
	var $details;

	
	function sendData(){
		$this->details['pass'] = $_REQUEST['password'];
		$this->details['name'] = $_REQUEST['name'];
		$this->details['homeaddress'] = $_REQUEST['home'];
		$this->details['studnum'] = $_REQUEST['studnum'];
		$this->details['cellnum'] = $_REQUEST['cellnum'];
		$this->details['course'] = $_REQUEST['course'];
		$this->details['college'] = $_REQUEST['college'];
		$this->details['classification'] = $_REQUEST['classification'];
		$this->details['parents'] = $_REQUEST['parents'];
		$this->details['contact'] = $_REQUEST['contact'];
		$this->details['occupants'] = $_REQUEST['occupants'];
		$this->details['deposit'] = $_REQUEST['deposit'];
		$this->details['rent'] = $_REQUEST['rent'];
		$this->details['start'] = $_REQUEST['start'];
		$this->details['debts'] = $_REQUEST['debts'];
		$this->details['unit_name'] = $_REQUEST['unit_name'];
		
	}
}

	$a = new StartContractController;
	$a->sendData();
	$unit = new Unit;
	$unit->sendContractDetails($a->details);
	$unit->connect();
	if($unit->isOccupied($a->details['unit_name'])){
		echo "Unit is already occupied!";
		die;
	}
	$unit->startContract($a->details['unit_name']);
	echo "<h3>Contract Started</h3>";
	echo "Password: ".$unit->getPassword()."<br >";
	echo "Lesse Name: ".$unit->getName()."<br >";
	echo "Home Address: ".$unit->getHomeAddress()."<br >";
	echo "Student Number: ".$unit->getStudentNumber()."<br >";
	echo "Cellphone Number: ".$unit->getCellphoneNumber()."<br >";
	echo "Course: ".$unit->getCourse()."<br >";
	echo "College: ".$unit->getCollege()."<br >";
	echo "Classification: ".$unit->getClassification()."<br >";
	echo "Parents: ".$unit->getParents()."<br >";
	echo "Contact: ".$unit->getContact()."<br >";
	echo "Occupants: ".$unit->getOccupants()."<br >";
	echo "Deposit: P".$unit->getDeposit()."<br >";
	echo "Rent: P".$unit->getRent()."<br >";
	echo "Start Date: ".$unit->getStart()."<br >";
	echo "Previous Debts Before Automation: ".$unit->getDebts()."<br >";
	
?>